package main.request;

import java.io.IOException;

import utils.Debug;
import main.process.FtpRequest;

public class RequestStor implements ProcessRequestInterface {
	private static class SingletonHolder
	{		
		/** Instance unique non préinitialisée */
		private final static RequestStor instance = new RequestStor();
	}
	
	public static RequestStor getInstance()
	{
		return SingletonHolder.instance;
	}
	
	@Override
	public void processRequest(String[] request, FtpRequest ftp) throws IOException {
		
		Debug.debug(this.getClass().getName(), request, ftp.getDebug());
		
		if(!request[0].equals("STOR"))
		{
			next(request, ftp);
		}
		else
		{
			ftp.write("502 Command not implemented\n");	
		}
	}

	@Override
	public void next(String[] request, FtpRequest ftp) throws IOException {
		RequestType.getInstance().processRequest(request, ftp);

	}

}
